]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
StTextureCache: never return fullcolor icons for ST_ICON_SYMBOLIC
authorDan Winship <danw@gnome.org>
Mon, 7 Mar 2011 17:47:07 +0000 (12:47 -0500)
committerDan Winship <danw@gnome.org>
Tue, 8 Mar 2011 14:36:55 +0000 (09:36 -0500)
g_themed_icon_new_with_default_fallbacks() does not do what we want
with symbolic icons; if the user's icon theme is not "gnome", then it
will end up preferring a non-symbolic icon from the higher-level theme
over a symbolic icon from gnome-icon-theme-symbolic.

If the shell requests a symbolic icon, and there is only a
non-symbolic icon available, that should be considered a programmer
error, just like requesting a non-existent icon name. So change the
code to only look up "-symbolic" names when drawing an
ST_ICON_SYMBOLIC icon.

https://bugzilla.gnome.org/show_bug.cgi?id=644142

src/st/st-texture-cache.c

index 52ce02ed0b06130e63c59964cd4bb3ba039c28e9..405cc177a3cd3d65d14e8e1ef6594a9fa0edc541 100644 (file)
@@ -1391,6 +1391,36 @@ st_texture_cache_load_sliced_image (StTextureCache    *cache,
  * icon you are loading, use %ST_ICON_FULLCOLOR.
  */
 
+/* generates names like g_themed_icon_new_with_default_fallbacks(),
+ * but *only* symbolic names
+ */
+static char **
+symbolic_names_for_icon (const char *name)
+{
+  char **parts, **names;
+  int i;
+
+  parts = g_strsplit (name, "-", -1);
+  names = g_new (char *, g_strv_length (parts) + 1);
+  for (i = 0; parts[i]; i++)
+    {
+      if (i == 0)
+        {
+          names[i] = g_strdup_printf ("%s-symbolic", parts[i]);
+        }
+      else
+        {
+          names[i] = g_strdup_printf ("%.*s-%s-symbolic",
+                                      (int) (strlen (names[i - 1]) - strlen ("-symbolic")),
+                                      names[i - 1], parts[i]);
+        }
+    }
+  names[i] = NULL;
+
+  g_strfreev (parts);
+  return names;
+}
+
 /**
  * st_texture_cache_load_icon_name:
  * @cache: The texture cache instance
@@ -1414,7 +1444,7 @@ st_texture_cache_load_icon_name (StTextureCache    *cache,
 {
   ClutterActor *texture;
   GIcon *themed;
-  char *symbolic;
+  char **names;
 
   g_return_val_if_fail (!(icon_type == ST_ICON_SYMBOLIC && theme_node == NULL), NULL);
 
@@ -1429,9 +1459,9 @@ st_texture_cache_load_icon_name (StTextureCache    *cache,
       return CLUTTER_ACTOR (texture);
       break;
     case ST_ICON_SYMBOLIC:
-      symbolic = g_strconcat (name, "-symbolic", NULL);
-      themed = g_themed_icon_new_with_default_fallbacks ((const gchar*)symbolic);
-      g_free (symbolic);
+      names = symbolic_names_for_icon (name);
+      themed = g_themed_icon_new_from_names (names, -1);
+      g_strfreev (names);
       texture = load_gicon_with_colors (cache, themed, size,
                                         st_theme_node_get_icon_colors (theme_node));
       g_object_unref (themed);